<template>
  <a-modal
    :title="isAdds?'新增':'修改'"
    :visible="iswriteBankVersion"
    @cancel="cancel"
    @ok="ok"
  >
  
  <a-form-model class="fromModels" ref="editlanguageModel"  :model="languageFormDatas"  layout="vertical" 
  :labelCol="{span: 6}" :wrapperCol="{span: 16}">
      <a-form-model-item label="类型">
        <a-select :disabled="!isAdds" v-model="languageFormDatas.type"  placeholder="请选择类型">
          <a-select-option v-for="(item,index) in typeArrs" :key="index" :value="item.id">{{ item.name }}</a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item label="code">
        <a-select :disabled="!isAdds" v-model="languageFormDatas.code"  placeholder="请选择code">
          <a-select-option v-for="(item,index) in codeArrs" :key="index" :value="item.code">{{ item.name }}</a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item label="名称">
        <a-input v-model="languageFormDatas.name" />
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import { editLanguageListApi } from '@/api/dict.js'
export default {
  name: 'writeBankDiogla',
  props:['typeArrs'],
  components: {
  },
  data() {
    return {
      codeArrs:[],
      iswriteBankVersion:false,
      languageFormDatas:{
        code:"",
        type:"",
        name:"",
      },
      isAdds:false
    }
  },
  created() {
  },
  computed:{
  },
  methods: {
    openwriteLanguageDiogla(json){
        this.languageFormDatas={
          code:"",
          type:"",
          name:"",
        }
      if(json){
        this.isAdds=false
        this.languageFormDatas={
          code:json.code,
          type:json.type,
          name:json.name,
          ids:json.id
        }
      }else{
        this.isAdds=true
      }
      this.iswriteBankVersion=true
    },
    cancel(){
      this.iswriteBankVersion=false
    },
    ok(){
      if(this.isAdds){
        this.addApis()
      }else{
        this.writeApis()
      }
    },

    addApis(){
    },
    writeApis(){
      var jsons={
        ids:this.languageFormDatas.ids,
        name:this.languageFormDatas.name,
        brand_id: process.env.VUE_APP_BRAND_ID,
      }
      editLanguageListApi(jsons).then(res=>{
        this.$message.success("操作成功");
        this.cancel()
        this.$emit("changes")
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
